package com.dqp.cslggroup.LostAndFound;


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.Button;

import androidx.appcompat.widget.Toolbar;

import com.dqp.cslggroup.R;
import com.dqp.cslggroup.UI.BaseActivity;
import com.dqp.cslggroup.Util.QQ;
import com.dqp.cslggroup.Util.ToastUtil;

import java.util.Objects;

public class chat extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chat);
        Toolbar toolbar = findViewById(R.id.include_toolbar);
        toolbar.setTitle("");
        setSupportActionBar(toolbar);
        Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
        initCmp();

    }

    private void initCmp() {
        Button dn = findViewById(R.id.qiang_dn);
        Button dn1 = findViewById(R.id.qiang_dn1);
        Button dh = findViewById(R.id.qiang_dh);
        Button swzlpt = findViewById(R.id.swzlpt);
        dn.setOnClickListener(v -> toChat("2331976867"));
        dn1.setOnClickListener(v -> toChat("3416789239"));
        dh.setOnClickListener(v -> toChat("3027115809"));
        swzlpt.setOnClickListener(v -> toChat("1430248186"));
    }

    public void toChat(String qq) {
        if (QQ.isQQClientAvailable(chat.this)) {
            final String qqUrl = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq + "&version=1";
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(qqUrl)));
        } else {
            ToastUtil.showToast("请安装QQ客户端");
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0 && resultCode == RESULT_OK) {
            setResult(RESULT_OK);
            super.onDestroy();
            this.finish();
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }


}
